<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>tango.util.container.more.CacheMap</title>
  <link href="./css/style.css" rel="stylesheet" type="text/css"/>
  <!-- <link href="./img/icon.png" rel="icon" type="image/png"/> -->
  <script type="text/javascript" src="./js/jquery.js"></script>
  <script type="text/javascript" src="./js/modules.js"></script>
  <script type="text/javascript" src="./js/quicksearch.js"></script>
  <script type="text/javascript" src="./js/navigation.js"></script>
  <!--<script type="text/javascript" src="./js/jquery.treeview.js"></script>-->
  <script type="text/javascript">
    var g_moduleFQN = "tango.util.container.more.CacheMap";
  </script>
  
</head>
<body>
<div id="content">
  <h1><a href="./htmlsrc/tango.util.container.more.CacheMap.html" class="symbol">tango.util.container.more.CacheMap</a></h1>
  
<p class="sec_header">License:</p>BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a>
<p class="sec_header">Version:</p>Initial release: April 2008
<p class="sec_header">Author:</p>Kris
<p class="sec_header">Since:</p>0.99.7
<dl>
<dt class="decl">class <a class="symbol _class" name="CacheMap" href="./htmlsrc/tango.util.container.more.CacheMap.html#L42" kind="class" beg="42" end="399">CacheMap</a><span class="tparams">(K, V, alias Hash = Container.hash, 
                      alias Reap = Container.reap, 
                      alias Heap = Container.Collect)</span>; <a title="Permalink to this symbol" href="#CacheMap" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L42">#</a></dt>
<dd class="ddef">
<div class="summary">CacheMap extends the basic hashmap type by adding a limit to 
        the number of items contained at any given time. In addition, 
        CacheMap sorts the cache entries such that those entries 
        frequently accessed are at the head of the queue, and those
        least frequently accessed are at the tail. When the queue 
        becomes full, old entries are dropped from the tail and are 
        reused to house new cache entries.</div>
In other words, it retains MRU items while dropping LRU when
        capacity is reached.
<p class="bl"/>
        This is great for keeping commonly accessed items around, while
        limiting the amount of memory used. Typically, the queue size 
        would be set in the thousands
<dl>
<dt class="decl"><a class="symbol _ctor" name="CacheMap.this" href="./htmlsrc/tango.util.container.more.CacheMap.html#L67" kind="ctor" beg="67" end="83">this</a><span class="params">(uint <em>capacity</em>)</span>; <a title="Permalink to this symbol" href="#CacheMap.this" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L67">#</a></dt>
<dd class="ddef">
<div class="summary">Construct a cache with the specified maximum number of 
                entries. Additions to the cache beyond this number will
                reuse the slot of the least-recently-referenced cache
                entry.</div></dd>
<dt class="decl"><a class="symbol _dtor" name="CacheMap.~this" href="./htmlsrc/tango.util.container.more.CacheMap.html#L91" kind="dtor" beg="91" end="94">~this</a>(); <a title="Permalink to this symbol" href="#CacheMap.~this" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L91">#</a></dt>
<dd class="ddef">
<div class="summary">clean up when done</div></dd>
<dt class="decl">void <a class="symbol _function" name="CacheMap.reaper" href="./htmlsrc/tango.util.container.more.CacheMap.html#L102" kind="function" beg="102" end="105">reaper</a><span class="tparams">(K, R)</span><span class="params">(K <em>k</em>, R <em>r</em>)</span>; <span class="attrs">[<span class="stc">static</span>]</span> <a title="Permalink to this symbol" href="#CacheMap.reaper" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L102">#</a></dt>
<dd class="ddef">
<div class="summary">Reaping callback for the hashmap, acting as a trampoline</div></dd>
<dt class="decl">uint <a class="symbol _function" name="CacheMap.size" href="./htmlsrc/tango.util.container.more.CacheMap.html#L112" kind="function" beg="112" end="115">size</a><span class="params">()</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#CacheMap.size" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L112">#</a></dt>
<dd class="ddef">
<div class="summary"></div></dd>
<dt class="decl">int <a class="symbol _function" name="CacheMap.opApply" href="./htmlsrc/tango.util.container.more.CacheMap.html#L123" kind="function" beg="123" end="140">opApply</a><span class="params">(int delegate(ref K key, ref V value) <em>dg</em>)</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#CacheMap.opApply" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L123">#</a></dt>
<dd class="ddef">
<div class="summary">Iterate from MRU to LRU entries</div></dd>
<dt class="decl">bool <a class="symbol _function" name="CacheMap.get" href="./htmlsrc/tango.util.container.more.CacheMap.html#L148" kind="function" beg="148" end="160">get</a><span class="params">(K <em>key</em>, ref V <em>value</em>)</span>; <a title="Permalink to this symbol" href="#CacheMap.get" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L148">#</a></dt>
<dd class="ddef">
<div class="summary">Get the cache entry identified by the given key</div></dd>
<dt class="decl">bool <a class="symbol _function" name="CacheMap.add" href="./htmlsrc/tango.util.container.more.CacheMap.html#L174" kind="function" beg="174" end="189">add</a><span class="params">(K <em>key</em>, V <em>value</em>)</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#CacheMap.add" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L174">#</a></dt>
<dd class="ddef">
<div class="summary">Place an entry into the cache and associate it with the
                provided key. Note that there can be only one entry for
                any particular key. If two entries are added with the 
                same key, the second effectively overwrites the first.</div>
Returns true if we added a new entry; false if we just
                replaced an existing one</dd>
<dt class="decl">bool <a class="symbol _function" name="CacheMap.take" href="./htmlsrc/tango.util.container.more.CacheMap.html#L198" kind="function" beg="198" end="203">take</a><span class="params">(K <em>key</em>)</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#CacheMap.take" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L198">#</a></dt>
<dd class="ddef">
<div class="summary">Remove the cache entry associated with the provided key. 
                Returns false if there is no such entry.</div></dd>
<dt class="decl">bool <a class="symbol _function" name="CacheMap.take:2" href="./htmlsrc/tango.util.container.more.CacheMap.html#L212" kind="function" beg="212" end="228">take</a><span class="params">(K <em>key</em>, ref V <em>value</em>)</span>; <span class="attrs">[<span class="stc">final</span>]</span> <a title="Permalink to this symbol" href="#CacheMap.take:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L212">#</a></dt>
<dd class="ddef">
<div class="summary">Remove (and return) the cache entry associated with the 
                provided key. Returns false if there is no such entry.</div></dd>
<dt class="decl">Ref <a class="symbol _function" name="CacheMap.deReference" href="./htmlsrc/tango.util.container.more.CacheMap.html#L237" kind="function" beg="237" end="250">deReference</a><span class="params">(Ref <em>entry</em>)</span>; <span class="attrs">[<span class="prot">private</span>]</span> <a title="Permalink to this symbol" href="#CacheMap.deReference" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L237">#</a></dt>
<dd class="ddef">
<div class="summary">Place a cache entry at the tail of the queue. This makes
                it the least-recently referenced.</div></dd>
<dt class="decl">Ref <a class="symbol _function" name="CacheMap.reReference" href="./htmlsrc/tango.util.container.more.CacheMap.html#L259" kind="function" beg="259" end="272">reReference</a><span class="params">(Ref <em>entry</em>)</span>; <span class="attrs">[<span class="prot">private</span>]</span> <a title="Permalink to this symbol" href="#CacheMap.reReference" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L259">#</a></dt>
<dd class="ddef">
<div class="summary">Move a cache entry to the head of the queue. This makes
                it the most-recently referenced.</div></dd>
<dt class="decl">Ref <a class="symbol _function" name="CacheMap.addEntry" href="./htmlsrc/tango.util.container.more.CacheMap.html#L282" kind="function" beg="282" end="299">addEntry</a><span class="params">(K <em>key</em>, V <em>value</em>)</span>; <span class="attrs">[<span class="prot">private</span>]</span> <a title="Permalink to this symbol" href="#CacheMap.addEntry" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L282">#</a></dt>
<dd class="ddef">
<div class="summary">Add an entry into the queue. If the queue is full, the
                least-recently-referenced entry is reused for the new
                addition.</div></dd>
<dt class="decl">struct <a class="symbol _struct" name="CacheMap.QueuedEntry" href="./htmlsrc/tango.util.container.more.CacheMap.html#L309" kind="struct" beg="309" end="398">QueuedEntry</a>; <span class="attrs">[<span class="prot">private</span>]</span> <a title="Permalink to this symbol" href="#CacheMap.QueuedEntry" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L309">#</a></dt>
<dd class="ddef">
<div class="summary">A doubly-linked list entry, used as a wrapper for queued 
                cache entries. Note that this class itself is a valid cache 
                entry.</div>
<dl>
<dt class="decl">Ref <a class="symbol _function" name="CacheMap.QueuedEntry.set" href="./htmlsrc/tango.util.container.more.CacheMap.html#L322" kind="function" beg="322" end="327">set</a><span class="params">(K <em>key</em>, V <em>value</em>)</span>; <a title="Permalink to this symbol" href="#CacheMap.QueuedEntry.set" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L322">#</a></dt>
<dd class="ddef">
<div class="summary">Set this linked-list entry with the given arguments.</div></dd>
<dt class="decl">Ref <a class="symbol _function" name="CacheMap.QueuedEntry.prepend" href="./htmlsrc/tango.util.container.more.CacheMap.html#L336" kind="function" beg="336" end="351">prepend</a><span class="params">(Ref <em>before</em>)</span>; <a title="Permalink to this symbol" href="#CacheMap.QueuedEntry.prepend" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L336">#</a></dt>
<dd class="ddef">
<div class="summary">Insert this entry into the linked-list just in 
                        front of the given entry.</div></dd>
<dt class="decl">Ref <a class="symbol _function" name="CacheMap.QueuedEntry.append" href="./htmlsrc/tango.util.container.more.CacheMap.html#L360" kind="function" beg="360" end="375">append</a><span class="params">(Ref <em>after</em>)</span>; <a title="Permalink to this symbol" href="#CacheMap.QueuedEntry.append" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L360">#</a></dt>
<dd class="ddef">
<div class="summary">Add this entry into the linked-list just after 
                        the given entry.</div></dd>
<dt class="decl">Ref <a class="symbol _function" name="CacheMap.QueuedEntry.extract" href="./htmlsrc/tango.util.container.more.CacheMap.html#L385" kind="function" beg="385" end="397">extract</a><span class="params">()</span>; <a title="Permalink to this symbol" href="#CacheMap.QueuedEntry.extract" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.more.CacheMap.html#L385">#</a></dt>
<dd class="ddef">
<div class="summary">Remove this entry from the linked-list. The 
                        previous and next entries are patched together 
                        appropriately.</div></dd></dl></dd></dl></dd></dl>
</div>
<div id="footer">
  <p>Copyright (c) 2008 Kris Bell. All rights reserved</p>
  <p>Page generated by <a href="http://code.google.com/p/dil">dil</a> on Fri Dec 26 04:04:08 2008. Rendered by <a href="http://code.google.com/p/dil/wiki/Kandil">kandil</a>.</p>
</div>
</body>
</html>